#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,ls,ans,south;
double d[100005],v[100005],a[100005],p[100005],k;
bool u[100005];
struct node{
    int l,r;
}s[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while (t--){
        int nn,mm,ll,kk;ls=0;ans=0;
        scanf("%d%d%d%d",&nn,&mm,&ll,&kk);
        n=nn,m=mm,l=ll,k=kk;
        for (int i=1;i<=n;i++){
            int dd,vv,aa;
            scanf("%d%d%d",&dd,&vv,&aa);
            d[i]=dd,v[i]=vv,a[i]=aa;
        }
        for (int i=1;i<=m;i++){
            int pp;
            scanf("%d",&pp);
            p[i]=pp;
        }
        for (int i=1;i<=n;i++){
            if (a[i]==0){
                if (v[i]>k){
                    ans++;
                    for (int j=1;j<=m;j++){
                        if (p[j]>=d[i]){
                            s[++ls].l=j;
                            s[ls].r=m;
                            break;
                        }
                    }
                }
            }
            else if (a[i]>0){
                if (v[i]>k){
                    ans++;
                    for (int j=1;j<=m;j++){
                        if (p[j]>=d[i]){
                            s[++ls].l=j;
                            s[ls].r=m;
                            break;
                        }
                    }
                }
                else{
                    double time=(k-v[i])/a[i];
                    double road=v[i]*time+0.5*a[i]*time*time;
                    for (int j=1;j<=m;j++){
                        if (p[j]>d[i]+road){
                            s[++ls].l=j;ans++;
                            s[ls].r=m;
                            break;
                        }
                    }
                }
            }
            else{
                if (v[i]<=k) continue;
                else{
                    int left=m,right=m;
                    double time=(k-v[i])/a[i];
                    double road=v[i]*time+0.5*a[i]*time*time;
               //     cout<<time<<" "<<road<<" "<<road+d[i]<<endl;
                    for (int j=1;j<=m;j++){
                        if (p[j]>=d[i]){
                            left=j;break;
                        }
                    }
                    for (int j=1;j<=m;j++){
                        if (p[j]>=d[i]+road){
                            right=j-1;
                            break;
                        }
                    }
               //     cout<<"->"<<left<<" "<<right<<endl;
                    if (left<=right){
                        ans++;
                        s[++ls].l=left;
                        s[ls].r=right;
                    }
                }
            }
        }
        printf("%d ",ans);
        ans=0;
     //   for (int i=1;i<=ls;i++){
     //       cout<<s[i].l<<" "<<s[i].r<<endl;
     //   }cout<<endl;
        memset(u,0,sizeof(u));
        for (int i=1;i<m;i++){
            int f=0;
            for (int j=1;j<=ls;j++){
                if (u[j]==1) continue;
                if (s[j].r==i){
                    f=1;break;
                }
            }
            if (f==1){
                ans++;
                for (int j=1;j<=ls;j++){
                    if (u[j]==1) continue;
                    if (s[j].l<=i&&s[j].r>=i) u[j]=1;
                }
            }
        }int f=0;
        for (int j=1;j<=ls;j++){
            if (u[j]==1) continue;
            if (s[j].l<=m&&s[j].r>=m){
                f=1;break;
            }
        }
        ans+=f;
        printf("%d\n",m-ans);
    }
    return 0;
}
